home *** CD-ROM | disk | FTP | other *** search
- (******************************************************************************
-
- EXTEND.ACC
- Version 1.1
- February 27, 1986
- by Randy Forgaard
- CompuServe 70307,521
-
-
- The following information can be used only with the DOS version of the Turbo
- (Database) Toolbox, under Turbo Pascal 3.0 and higher.
-
- This file is for use with the Turbo Access portion of the MS-DOS Turbo
- (Database) Toolbox Version 1.2, together with MS-DOS or PC-DOS Turbo Pascal
- 3.01A or higher (regular, 8087, or BCD version). If you have Version 1.00,
- 1.01, or 1.1 of the Toolbox, see the file TBXFIX in DL 1 of the Borland SIG for
- the source code changes that will upgrade your copy to Version 1.2 (plus
- additional fixes). If you have Version 3.00A or 3.00B of Turbo Pascal, arrange
- with Borland Customer Service to upgrade your copy of Turbo to 3.01A or higher
- (3.00A and 3.00B are not compatible with Turbo Database Toolbox). The routines
- below will not work with earlier (pre-3.0) versions of Turbo Pascal, nor with
- Turbo Pascal for operating systems other than DOS.
-
- Normally, when using the Turbo (Database) Toolbox with Turbo Pascal 3.0 and
- higher, only 15 total files (Toolbox files and other files/devices manipulated
- by the program) can be open at the same time, due to limitations in DOS. The
- information below shows you how to have up to 96 total files open
- simultaneously under DOS 2.0 or 2.1, or 252 files open simultaneously under DOS
- 3.0 or higher. This technique is totally internal to the Toolbox; after making
- the indicated Toolbox changes, you will not have to change the source code of
- your programs that use the Toolbox (except to add a compiler directive and an
- include file; see below).
-
- The code below uses the routines in EXTEND.PAS, also in DL 1 of the Borland
- CompuServe SIG. EXTEND.PAS shows how to use this technique for any kind of
- Turbo file, not just Toolbox files. Your program can use EXTEND.PAS directly,
- in addition to the changes mentioned below for the Toolbox. The 96 (or 252)
- limit of simultaneously open files will apply to the total of all Toolbox files
- and other files that your program uses. For those interested in the technical
- underpinnings of this method, please see the documentation in EXTEND.PAS.
-
- There are some other files in DL 1 of the Borland SIG that may be of interest.
- These files describe how to modify the Database Toolbox to extend it for
- various other purposes; e.g., FLUSH.ACC describes Toolbox modifications that
- provide automatic "flushing" of DataFiles and IndexFiles under DOS Turbo 3.0,
- to guard against file corruption in the event of a system crash, and BIGTRE.BOX
- shows how to use more than 65535 records per DataFile under DOS. The
- modifications below have been tested with FLUSH.ACC, so you may use the
- FLUSH.ACC and EXTEND.ACC modifications together. However, the BIGTRE.BOX
- modifications have not yet been examined with respect to FLUSH.ACC and
- EXTEND.ACC. Try a "BRO/KEY:TOOLBOX" and a "BRO/KEY:ACCESS" to find these and
- other files in DL 1.
-
- Note: If you are using both the EXTEND.ACC modifications and the FLUSH.ACC
- modifications, you must apply the FLUSH.ACC modifications first, THEN the
- modifications below.
-
-
-
- MODIFYING ACCESS.BOX:
-
- This method only works with Turbo 3.0 and higher. Make the following
- modifications to the indicated procedures/functions in ACCESS.BOX or
- ACCESS3.BOX, whichever is intended for use with Turbo 3.0. Check the comment
- header at the beginning of the file to ensure you are using the correct
- ACCESS.BOX. Please BE SURE to make a backup copy of the ACCESS.BOX file before
- making these changes.
-
-
- 1. In GetRec:
- -------------
-
- Add the following line immediately after the "begin":
- UnExtend(DatF.F);
-
- Add the following line immediately after the "BlockRead(...);" statement:
- ReExtend(DatF.F);
-
-
- 2. In PutRec:
- -------------
-
- Add the following line immediately after the "begin":
- UnExtend(DatF.F);
-
- Add the following line immediately after the "BlockWrite(...);" statement:
- ReExtend(DatF.F);
-
-
- 3. In MakeFile:
- ---------------
-
- Add the following line immediately after the "Move(...);" statement:
- OpenExtend(DatF.F);
-
-
- 4. In OpenFile:
- ---------------
-
- Add the following line immediately BEFORE the "GetRec(...);" statement:
- OpenExtend(DatF.F);
-
- Add the following line immediately after the "Move(...);" statement:
- UnExtend(DatF.F);
-
- Add the following line immediately after the "DatF.NumRec := ...;" statement:
- ReExtend(DatF.F);
-
-
- 5. In CloseFile:
- ----------------
-
- Add the following line immediately after the "PutRec(...);" statement:
- UnExtend(DatF.F);
-
- Add the following line immediately after the "Close(...);" statement:
- ReExtend(DatF.F);
-
-
- NOTE: If you have modified ACCESS.BOX as per FLUSH.ACC, make the following
- additional changes:
-
-
- 6. In FlushFile:
- ----------------
-
- Add the following line immediately BEFORE the "Seek(...);" statement:
- UnExtend(DatF.F);
-
- Add the following line immediately after the FIRST "MsDos(...);" statement:
- ReExtend(DatF.F);
-
-
- 7. In FlushIndex:
- -----------------
-
- Add the following line immediately BEFORE the "Seek(...);" statement:
- UnExtend(IdxF.DataF.F);
-
- Add the following line immediately after the "BlockWrite(..);" statement:
- ReExtend(IdxF.DataF.F);
-
-
-
- TO USE THIS TECHNIQUE:
-
- Make the above modifications. Then --
-
- At the very top of your program, prior to the "program" statement, put the
- compiler directive {$F252}. (You may use a value smaller than 252, if you
- wish. Under DOS 2.0/2.1, values above 96 have no additional benefit. Each
- larger value for the {$F} directive uses 2 additional bytes in the program's
- global data space.) The value you specify for the {$F} directive is the
- maximum number of files you will be able to have open at the same time in your
- program.
-
- In your program, PRIOR to the {$I ACCESS.BOX} (or {$I ACCESS3.BOX}), insert a
- line that says {$I EXTEND.PAS}, to include the EXTEND.PAS file (available in
- DL 1 of the Borland SIG).
-
- Edit your CONFIG.SYS file (see the DOS manual for details), so that it includes
- a line that says "FILES=XXX". XXX should be a number that is 3 greater than
- the value you specified for the {$F} directive (larger values will provide no
- additional benefit, with respect to your individual program), and should not
- exceed 99 (for DOS 2.0/2.1) or 255 (for DOS 3.0 and higher). Under any version
- of DOS, the minimum allowable value for XXX is 8. Then, reboot your computer
- so that the FILES=XXX parameter takes hold. That's it!
-
- Note: EXTEND.PAS uses a typed constant whose value changes during the course of
- execution. Consequently, when compiling any program that uses EXTEND.PAS
- (including programs that use the EXTEND.ACC technique), you must either: 1)
- compile the program in memory and run it ONCE only, or 2) compile the program
- to a .COM file, and execute the .COM file. The program will bomb if you: 1)
- compile the program in memory and then run the program more than once, or 2)
- compile and run the program in memory, and then immediately compile to a .COM
- file without first leaving and restarting Turbo.
-
- Running the sample program below will tell you the maximum number of files you
- can have open at once (usually 96 or 252, unless a resident program has files
- open, or unless there are some orphaned files due to previous program error).
- This program takes a while to run, due to the heavy disk I/O, so running it on
- a hard disk (or, even better, a RAM disk) is recommended. Make sure that you
- are running the program in a subdirectory, so that you don't run up against the
- DOS limit on the number of allowable files in the root directory of a drive.
- Have fun!
-
-
-
- Many thanks to Bela Lubkin (CompuServe 76703,3015) for masterminding this idea,
- and to Kim Kokkonen (CompuServe 72457,2131) and Scott Bussinger (CompuServe
- 72247,2671) for helping me debug it. If you have any questions, comments, or
- trouble with the above changes, please feel free to contact me on the Borland
- SIG or via EasyPlex on CompuServe. I sincerely hope the above information is
- useful to you!
-
- Change Log:
-
- Version 1.1: Fixes an important bug, pointed out by Scott Bussinger, in the
- changes to MakeFile and OpenFile, above. Also, adds a caveat
- about compiling programs that use EXTEND.PAS (including
- EXTEND.ACC).
-
- ******************************************************************************)
-
- {$F252}
-
- {Turbo Access constants}
- const
- MaxDataRecSize = 17;
- MaxKeyLen = 10;
- PageSize = 24;
- Order = 12;
- PageStackSize = 10;
- MaxHeight = 4;
-
- {$I EXTEND.PAS}
- {$I ACCESS.BOX} {IMPORTANT: Or ACCESS3.BOX...whichever file you modified}
-
- const
- MaxCount = 255;
- SampleData: string[16] = 'Some sample data';
- var
- fn: string[14];
- f: array[1..MaxCount] of DataFile;
- i, count, dataRef: Integer;
- temp: File;
- begin
- writeln('Opening files...');
- i := 0;
- repeat
- i := i + 1;
- Str(i, fn);
- fn := 'junk' + fn + '.dat';
- Assign(temp, fn);
- {$I-} Rewrite(temp); {$I+}
- OK := IOResult = 0;
- if OK then
- begin
- Close(temp);
- MakeFile(f[i], fn, MaxDataRecSize)
- end
- until not OK;
- count := i - 1;
- writeln('Successfully opened ', count, ' files at the same time. ',
- 'Writing to each file...');
- for i := 1 to count do AddRec(f[i], dataRef, SampleData);
- writeln('Closing each file...');
- for i := 1 to count do CloseFile(f[i]);
- writeln('Erasing each file...');
- for i := 1 to count do
- begin
- Str(i, fn);
- Assign(temp, 'junk' + fn + '.dat');
- Erase(temp)
- end;
- writeln('Done.')
- end.